package com.chixing.util;

public class ServerResult {
  private int code;
  private String reason;
  private static Object data;

  //get,set

  public int getCode() {
    return code;
  }

  public void setCode(int code) {
    this.code = code;
  }

  public String getReason() {
    return reason;
  }

  public void setReason(String reason) {
    this.reason = reason;
  }

  public  Object getData() {
    return data;
  }

  public void setData(Object data) {
    this.data = data;
  }

  //有参无参


  public ServerResult() {
  }

  public ServerResult(int code, String reason, Object data) {
    this.code = code;
    this.reason = reason;
    this.data = data;
  }

  //查询成功
  public static ServerResult getSuccess(Object data) {
    return new ServerResult(200,"查询数据成功",data);
  }
  //查询失败
  public static ServerResult getFail(Object data) {
    return new ServerResult(201,"查询数据失败",data);
  }
  public static ServerResult postSuccess(Object data) {
    return new ServerResult(200,"添加数据成功",data);
  }
  public static ServerResult postFail(Object data) {
    return new ServerResult(201,"添加数据失败",data);
  }
  public static ServerResult putSuccess(Object data) {
    return new ServerResult(200,"修改数据成功",data);
  }
  public static ServerResult putFail(Object data) {
    return new ServerResult(201,"修改数据失败",data);
  }
  public static ServerResult deleteSuccess(Object data) {
    return new ServerResult(200,"删除数据成功",data);
  }
  public static ServerResult deleteFail(Object data) {
    return new ServerResult(201,"删除数据失败",data);
  }

  public static ServerResult loginSuccess(Object data) {
    return new ServerResult(200,"登录成功",data);
  }
  public static ServerResult loginFail(Object data) {
    return new ServerResult(201,"登录失败",data);
  }
  public static ServerResult registSuccess(Object data) {
    return new ServerResult(200,"注册成功",data);
  }
  public static ServerResult registFail(Object data) {
    return new ServerResult(201,"注册失败",data);
  }
}
